import {Result} from '@/base/Result';
import {request} from '@/base/Request';
import {Page} from '@/base/Page';
import {Company} from '@/base/model/Company';
import qs from 'qs';
import { Music } from '../model/Music';

interface CompanyVM {
  address: string,
  city: string,
  cityId: string,
  clientUrl: string,
  district: string,
  districtId: string,
  name: string,
  phone: string,
  province: string,
  provinceId: string,
  shortName: string
}

export function getMusicList(params: {
  pageIndex: number,
  pageSize: number,
  musicName?: string,
  englishName?: string,
}): Promise<Result<Page<Music>>> {
  return request.getPage(Music, '/api/music', {params});
}

export function putMusic(params: Music): Promise<Result<Music>> {
    let formData = new FormData();
    Object.keys(params).forEach(x => {
    formData.append(x, params[x]);
  });
  return request.put(Music, `/api/music`, formData);
}

export function postMusic(params: Music): Promise<Result<Music>> {
  let formData = new FormData();
  Object.keys(params).forEach(x => {
    formData.append(x, params[x]);
  });
  return request.post(Music, '/api/music', formData);
}

export function getMusic(id: number): Promise<Result<Music>> {
  return request.get(Music, `/api/music/${id}`);
}

export function deleteMusic(id: number): Promise<Result<void>> {
  return request.delete(`/api/music/${id}`);
}
